fo = open("out.ps","w")

fo.write("%PS\n")

##########

scl = 10##

##########
vniz = False

vverh = False

fill = False

single = False

dve = False

tri = False

chet = False

piat = False

shest = False

toch_sh = False

sh_toch = False

line = 650

C = line - scl*1.5

D = line - scl*1

E = line - scl*0.5

F = line - scl*0

onen = C

twon = C

thren = C

fon = C

onesh = scl*4

px = range(10,730,scl*3)
n = C
i = 0
def nota():
	global i,scl,n

        fo.write("newpath\n")

        fo.write(str(px[i]) + " " + str(n) + " moveto\n")

        fo.write(str(px[i]+scl) + " " + str(n+scl) + " lineto\n")

        fo.write("stroke\n")
def shtil():
	global i,scl,onesh,n
	fo.write("newpath\n")

        fo.write(str(px[i]+scl) + " " + str(n+scl) + " moveto\n")

        fo.write(str(px[i]+scl) + " " + str(n+scl+onesh) + " lineto\n")

        fo.write("stroke\n")

def stan():

    global line

    fo.write("newpath\n")

    for linii in range(line,int(line+scl*5),scl):

        fo.write("0 " + str(line) + " moveto\n")

        fo.write("740 " + str(line) + " lineto\n")

        line = line + scl

    fo.write("stroke\n")

while True:

    inp = raw_input()

    if inp == "S":

        stan()

    for notes in inp:

        print notes

        if notes == "4":

            chet = True

            continue

        if chet == True:

            if notes == "C":
		if i == 3:	
			fon = C
                	fo.write("newpath\n")

                	fo.write(str(px[i]-scl/2) + " " + str(line-scl*6) + " moveto\n")

                	fo.write(str(px[i]+scl*1.5) + " " + str(line-scl*6) + " lineto\n")

                	fo.write("stroke\n")
			n = C
			nota()
			shtil()
			i = i - 2
		elif i == 0:
	    		print "CCCC"
			onen = C		
			nota()
			fo.write("newpath\n")

                	fo.write(str(px[i]-scl/2) + " " + str(line-scl*6) + " moveto\n")

                	fo.write(str(px[i]+scl*1.5) + " " + str(line-scl*6) + " lineto\n")

                	fo.write("stroke\n")
			shtil()
			i = i + 3
            elif notes == "D":
		print str(i) + "((((((((((((())))))))))))))))"
		if i == 2:
			print "PPPPPPPPPPPPPPPPPP"
			thren = D
                	n = D
			nota()
		elif i == 1:
			print "DDDDD"
			twon = D
			n = D
			nota()
                if onen == C and fon == F or onen == F and fon == C:
                    onesh = scl*4
		    shtil()
		    i = i + 1
            elif notes == "E":
		if i == 1:
			print "{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}"
			twon = E
                	n = E
			nota()
		elif i == 2:
			print "EEEE"+str(i)
                	thren = E
			n = E
			nota()
		elif i == 3:
			print "EEEEEEEEEEEE"+str(i)
                	fon = E
			n = E
			nota()
                	if onen == C and fon == F or onen == F and fon == C:
		    		print str(i) + "UUUUUUUUUUUUUUUUUUU"
                    		onesh = scl*4
		    		shtil()
		    		i = i + 1
			elif onen == C and fon == E:
				print str(i) + "IIIIIIIIIIIIIIIIIIII"
                    		onesh = scl*4
		    		shtil()
		    		i = i - 2	
            elif notes == "F":
		if i == 0:
			onen = F
                	n = F
			nota()
			shtil()
			i = i + 3
		elif i == 1:
			twon = F
                	n = F
			nota()
			if onen == C and fon == C:
		    		print str(i) + "UUUUUUUUUUUUUUUUUUU"
                    		onesh = scl*2.5
		    		shtil()
				i = i + 1
			elif onen == C and fon == E:
		   	 	print str(i) + "UUUUUUUUUUUUUUUUUUU"
                    		onesh = scl*2.8
		   	 	shtil()	
				i = i + 1
		elif i == 2:
			thren = F
                	n = F
			nota()
			if onen == C and fon == C:
		    		print str(i) + "UUUUUUUUUUUUUUUUUUU"
                    		onesh = scl*2.5
		    		shtil()
			elif onen == C and fon == E:
		   	 	print str(i) + "UUUUUUUUUUUUUUUUUUU"
                    		onesh = scl*3.2
		   	 	shtil()	
				i = i - 2
		elif i == 3:
			print "FFFFF"+str(i)
			fon = F
			n = F
			nota()
			if onen == C and fon == C:
		    		print str(i) + "UUUUUUUUUUUUUUUUUUU"
                    		onesh = scl*2.5
		    		shtil()
			elif onen == C and fon == E:
		   	 	print str(i) + "UUUUUUUUUUUUUUUUUUU"
                    		onesh = scl*3
		   	 	shtil()	
				i = i - 2
            elif notes == ")":
		onesh = scl*4
                print "))))))"+str(i)
                fo.write("newpath\n")

                fo.write(str(px[i-2]+scl) + " " + str(onen+onesh+scl) + " moveto\n")

                fo.write(str(px[i+1]+scl) + " " + str(fon+onesh+scl) + " lineto\n")

                fo.write("stroke\n")

    if inp == "q":

        break

fo.write("showpage\n")

fo.close()
